import request from '@/utils/request'
import da from "element-ui/src/locale/lang/da";

let domainName = '';
let publicAddress = "/prod-api/wechat";

//创建小程序接口
export function registerApplet(data) {
  return request({
    url: domainName+publicAddress+'/applet/register/applet',
    method: 'post',
    data: data
  })
}

//查询创建任务状态
export function FindCreateTask(data) {
  return request({
    url: domainName+publicAddress+'/applet/register/findCreateTask',
    method: 'post',
    data: data
  })
}

//复用公众号主体注册小程序(跳转授权页)
export function Fastregisterauth(indexUrl,authorizationInfo) {
  const data = {
    indexUrl,
    authorizationInfo
  }
  return request({
    url: domainName+publicAddress+'/applet/fastregisterauth',
    method: 'post',
    data:data
  })
}

//换绑小程序管理员接口
export function IntieAdmin(indexUrl,authorizationType) {
  const data = {
    indexUrl,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/IntieAdmin',
    method: 'post',
    data:data
  })
}



//小程序授权
export function appletGrant(indexUrl,authorizationType,authorizationStatus) {
  console.log("授权请求值indexUrl:"+indexUrl+",authorizationType:"+authorizationType+",authorizationStatus"+authorizationStatus)
  const data = {
    indexUrl,
    authorizationType,
    authorizationStatus
  }
  return request({
    url: domainName+publicAddress+'/weixin/grant',
    method: 'post',
    data:data
  })
}

//获取基本信息
export function getAppletInfo() {
  console.log("获取基本信息")
  return request({
    url: domainName+publicAddress+'/applet/getAppletInfo',
    method: 'get',
  })
}

//获取授权方账号信息
export function getAuthorizerInfo(authorizationType) {
  console.log("获取授权方账号信息,类型为："+authorizationType)
  return request({
    url: domainName+publicAddress+'/applet/getAuthorizerInfo',
    method: 'post',
    data: authorizationType
  })
}

//设置服务器域名
export function modifyDomain(action) {
  console.log("设置服务器域名,请求类型为"+action)
  return request({
    url: domainName+publicAddress+'/applet/editDomain',
    method: 'post',
    data: action
  })
}

//设置服务器域名
export function webviewdomain(action) {
  console.log("设置业务域名,请求类型为"+action)
  return request({
    url:domainName+publicAddress+'/applet/setwebviewdomain',
    method: 'post',
    data: action
  })
}

//绑定微信用户为体验者
export function bindTesterRequest(experienceId,authorizationType) {
  const data = {
    experienceId,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/bindTester',
    method: 'post',
    data: data
  })
}


//获取体验者列表
export function getbindTesterRequesr(authorizationType) {
  return request({
    url: domainName+publicAddress+'/applet/getbindTester',
    method: 'post',
    data:authorizationType
  })
}

//解除绑定体验者
export function unbindTesterRequest(experienceId,authorizationType) {
  const data = {
    experienceId,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/unbindTester',
    method: 'post',
    data: data
  })
}

//获取代码模板列表
export function gettemplatelistRequest(templateType) {
  console.log("获取代码模板列表")
  return request({
    url: domainName+publicAddress+'/applet/gettemplatelist',
    method: 'post',
    data:templateType
  })
}

//上传代码
export function uploadCodeRequest(data) {
  console.log("上传代码:"+data)
  return request({
    url: domainName+publicAddress+'/applet/uploadCode',
    method: 'post',
    data:data
  })
}


//获取体验版二维码
export function getQrcodeRequest(authorizationType) {
  console.log("获取体验版二维码")
  return request({
    url: domainName+publicAddress+'/applet/getQrcode',
    method: 'post',
    data:authorizationType
  })
}

//提交审核
export function submitAuditRequest(releaseType,funcType,authorizationType) {
  const data = {
    releaseType,
    funcType,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/submitAudit',
    method: 'post',
    data:data
  })
}

//查询最新一次提交的审核状态
export function getAuditstatusRequest(authorizationType) {
  return request({
    url: domainName+publicAddress+'/applet/getLatestAuditstatus',
    method: 'post',
    data:authorizationType
  })
}


//小程序审核撤回
export function undocodeauditRequest() {
  console.log("小程序审核撤回")
  return request({
    url: domainName+publicAddress+'/applet/undocodeaudit',
    method: 'get'
  })
}


//发布已通过审核的小程序
export function releaseRequest(authorizationType) {
  return request({
    url: domainName+publicAddress+'/applet/release',
    method: 'post',
    data:authorizationType
  })
}

//版本回退
export function revertcodereleaseRequest(appVersion) {
  console.log("小程序审核撤回"+appVersion)
  return request({
    url: domainName+publicAddress+'/applet/revertcoderelease',
    method: 'post',
    data:appVersion
  })
}

//设置最低基础库版本
export function setversionRequest(version) {
  console.log("设置最低基础库版本"+version)
  return request({
    url: domainName+publicAddress+'/applet/setweappsupportversion',
    method: 'post',
    data:version
  })
}

//查询服务商的当月提审限额
export function queryquotaRequest() {
  console.log("查询服务商的当月提审限额")
  return request({
    url: domainName+publicAddress+'/applet/queryquota',
    method: 'get'
  })
}

//加急审核申请
export function speedupauditRequest(auditid) {
  console.log("加急审核申请"+auditid)
  return request({
    url:domainName+publicAddress+'/applet/speedupaudit',
    method: 'post',
    data:auditid
  })
}

//获取已设置的所有类目
export function getcategoryRequest() {
  console.log("获取已设置的所有类目")
  return request({
    url: domainName+publicAddress+'/applet/getcategory',
    method: 'get'
  })
}


//添加类目
export function addcategoryRequest(first,second,authorizationType) {
  const data = {
    first,
    second,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/addcategory',
    method: 'post',
    data:data
  })
}

//删除类目
export function deletecategoryRequest(first,second,authorizationType) {
  const data = {
    first,
    second,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/deletecategory',
    method: 'post',
    data:data
  })
}

//获取小程序违规处罚记录
export function getillegalrecordsRequest(authorizationType) {
  console.log("获取小程序违规处罚记录"+authorizationType)
  return request({
    url: domainName+publicAddress+'/applet/getillegalrecords',
    method: 'post',
    data:authorizationType
  })
}

//获取小程序申诉记录
export function getappealrecordsRequest(illegalRecordId,authorizationType) {
  const data = {
    illegalRecordId,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/getappealrecords',
    method: 'post',
    data:data
  })
}

// 获取url link
export function generateUrllinkRequest() {
  console.log(" 获取url link")
  return request({
    url: domainName+publicAddress+'/applet/generateUrllink',
    method: 'post'
  })
}

// 获取小程序scheme码
export function generateschemeRequest() {
  console.log("获取小程序scheme码")
  return request({
    url: domainName+publicAddress+'/applet/generatescheme',
    method: 'post'
  })
}

// 设置名称
export function setAppletNameRequest(nickName,media_id,authorizationType) {
  console.log("设置名称")
  const data = {
    nickName,
    media_id,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/setAppletName',
    method: 'post',
    data:data
  })
}

// 修改头像
export function modifyheadimageRequest(data) {
  console.log("修改头像")
  return request({
    url: domainName+publicAddress+'/applet/modifyheadimage',
    method: 'post',
    data:data
  })
}

// 修改简介
export function modifysignatureRequest(signature,authorizationType) {
  const data = {
    signature,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/modifysignature',
    method: 'post',
    data:data
  })
}

// 新增临时素材
export function saveTemporaryMaterialRequest(platformid) {
  console.log("新增临时素材")
  return request({
    url: domainName+publicAddress+'/applet/saveTemporaryMaterial?platformid='+platformid,
    method: 'post'
  })
}

// 获取临时素材
export function getTemporaryMaterialRequest(mediaId) {
  console.log("新增临时素材")
  return request({
    url: domainName+publicAddress+'/applet/getTemporaryMaterial',
    method: 'post',
    data:mediaId
  })
}

// 获取平台id
export function getPlatFromId() {
  return request({
    url: domainName+publicAddress+'/applet/getPlatFromId',
    method: 'get'
  })
}

//设置支付方式
export function setPaymentTypeRequest(MerchantID,authorizationType) {
  const data = {
    MerchantID,
    authorizationType
  }
  return request({
    url: domainName+publicAddress+'/applet/setPaymentType',
    method: 'post',
    data:data
  })
}

//获取所有可设置的类目
export function getallcategoriesRequest() {
  return request({
    url: domainName+publicAddress+'/applet/getallcategories',
    method: 'get'
  })
}

//小程序登录
export function appletLoginRequest(code) {
  return request({
    url: domainName+publicAddress+'/openWechat/appletLogin',
    method: 'post',
    data:code,
    headers:{
      appid:'wx7225bfeb3feda204'
    }
  })
}

//判断是否绑定第三方
export function isBindThirdParty(authorizationType) {
  return request({
    url: domainName+publicAddress+'/applet/isBindThirdParty/'+authorizationType,
    method: 'get'
  })
}

//判断是否绑定第三方
export function getPayAuditStatus() {
  return request({
    url: domainName+publicAddress+'/applet/getPayAuditStatus',
    method: 'get'
  })
}
